class Solution
{
public:
    vector<bool> canMakePaliQueries(string s, vector<vector<int>> &queries)
    {
        int n = s.size();
        vector<vector<int>> prefixCount;
        prefixCount.push_back(vector<int>(26, 0));
        for (char c : s)
        {
            prefixCount.push_back(prefixCount.back());
            prefixCount.back()[c - 'a'] += 1;
        }

        vector<bool> result;
        for (auto &query : queries)
        {
            auto &backCount = prefixCount[query[1] + 1];
            auto &foreCount = prefixCount[query[0]];
            int oddCount = 0;
            for (int i = 0; i < 26; ++i)
            {
                if ((backCount[i] - foreCount[i]) & 1)
                {
                    ++oddCount;
                }
            }
            result.push_back(oddCount < 2 * query[2] + 2);
        }
        return result;
    }
};